﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

namespace Sunlit.Business.Migrations
{
    public partial class addentities : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "AbpCommerceCates",
                columns: table => new
                {
                    Id = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    Name = table.Column<string>(maxLength: 256, nullable: false),
                    ImageUrl = table.Column<string>(nullable: true),
                    ShowOnHome = table.Column<bool>(nullable: false),
                    ShortDesc = table.Column<string>(maxLength: 512, nullable: true),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    ParentId = table.Column<int>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_AbpCommerceCates", x => x.Id);
                    table.ForeignKey(
                        name: "FK_AbpCommerceCates_AbpCommerceCates_ParentId",
                        column: x => x.ParentId,
                        principalTable: "AbpCommerceCates",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                });

            migrationBuilder.CreateTable(
                name: "AbpEnterpriseCates",
                columns: table => new
                {
                    Id = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    Name = table.Column<string>(maxLength: 256, nullable: false),
                    ImageUrl = table.Column<string>(nullable: true),
                    ShowOnHome = table.Column<bool>(nullable: false),
                    ShortDesc = table.Column<string>(maxLength: 512, nullable: true),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    ParentId = table.Column<int>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_AbpEnterpriseCates", x => x.Id);
                    table.ForeignKey(
                        name: "FK_AbpEnterpriseCates_AbpEnterpriseCates_ParentId",
                        column: x => x.ParentId,
                        principalTable: "AbpEnterpriseCates",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                });

            migrationBuilder.CreateTable(
                name: "AbpHomeSliders",
                columns: table => new
                {
                    Id = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    Title = table.Column<string>(maxLength: 256, nullable: true),
                    ImageUrl = table.Column<string>(maxLength: 512, nullable: false),
                    LinkUrl = table.Column<string>(maxLength: 512, nullable: true),
                    SliderType = table.Column<int>(nullable: false),
                    DisplayOrder = table.Column<int>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_AbpHomeSliders", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "AbpPolicyCates",
                columns: table => new
                {
                    Id = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    Name = table.Column<string>(maxLength: 256, nullable: false),
                    ImageUrl = table.Column<string>(nullable: true),
                    ShowOnHome = table.Column<bool>(nullable: false),
                    ShortDesc = table.Column<string>(maxLength: 512, nullable: true),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    ParentId = table.Column<int>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_AbpPolicyCates", x => x.Id);
                    table.ForeignKey(
                        name: "FK_AbpPolicyCates_AbpPolicyCates_ParentId",
                        column: x => x.ParentId,
                        principalTable: "AbpPolicyCates",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                });

            migrationBuilder.CreateTable(
                name: "AbpServeCates",
                columns: table => new
                {
                    Id = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    Name = table.Column<string>(maxLength: 256, nullable: false),
                    ImageUrl = table.Column<string>(nullable: true),
                    ShowOnHome = table.Column<bool>(nullable: false),
                    ShortDesc = table.Column<string>(maxLength: 512, nullable: true),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    ParentId = table.Column<int>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_AbpServeCates", x => x.Id);
                    table.ForeignKey(
                        name: "FK_AbpServeCates_AbpServeCates_ParentId",
                        column: x => x.ParentId,
                        principalTable: "AbpServeCates",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                });

            migrationBuilder.CreateTable(
                name: "AbpCommerces",
                columns: table => new
                {
                    Id = table.Column<long>(nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    Title = table.Column<string>(maxLength: 256, nullable: false),
                    ImageUrl = table.Column<string>(maxLength: 512, nullable: true),
                    ShortDesc = table.Column<string>(maxLength: 512, nullable: true),
                    Content = table.Column<string>(nullable: false),
                    Hits = table.Column<int>(nullable: false),
                    RegionId = table.Column<int>(nullable: true),
                    CommerceCateId = table.Column<int>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_AbpCommerces", x => x.Id);
                    table.ForeignKey(
                        name: "FK_AbpCommerces_AbpCommerceCates_CommerceCateId",
                        column: x => x.CommerceCateId,
                        principalTable: "AbpCommerceCates",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_AbpCommerces_AbpUsers_CreatorUserId",
                        column: x => x.CreatorUserId,
                        principalTable: "AbpUsers",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_AbpCommerces_AbpRegions_RegionId",
                        column: x => x.RegionId,
                        principalTable: "AbpRegions",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                });

            migrationBuilder.CreateTable(
                name: "AbpEnterprises",
                columns: table => new
                {
                    Id = table.Column<long>(nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    Title = table.Column<string>(maxLength: 256, nullable: false),
                    ImageUrl = table.Column<string>(maxLength: 512, nullable: true),
                    ShortDesc = table.Column<string>(maxLength: 512, nullable: true),
                    Content = table.Column<string>(nullable: false),
                    Hits = table.Column<int>(nullable: false),
                    RegionId = table.Column<int>(nullable: true),
                    EnterpriseCateId = table.Column<int>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_AbpEnterprises", x => x.Id);
                    table.ForeignKey(
                        name: "FK_AbpEnterprises_AbpUsers_CreatorUserId",
                        column: x => x.CreatorUserId,
                        principalTable: "AbpUsers",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_AbpEnterprises_AbpEnterpriseCates_EnterpriseCateId",
                        column: x => x.EnterpriseCateId,
                        principalTable: "AbpEnterpriseCates",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_AbpEnterprises_AbpRegions_RegionId",
                        column: x => x.RegionId,
                        principalTable: "AbpRegions",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                });

            migrationBuilder.CreateTable(
                name: "AbpPolicies",
                columns: table => new
                {
                    Id = table.Column<long>(nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    Title = table.Column<string>(maxLength: 256, nullable: false),
                    ImageUrl = table.Column<string>(maxLength: 512, nullable: true),
                    ShortDesc = table.Column<string>(maxLength: 512, nullable: true),
                    Content = table.Column<string>(nullable: false),
                    Hits = table.Column<int>(nullable: false),
                    RegionId = table.Column<int>(nullable: true),
                    PolicyCateId = table.Column<int>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_AbpPolicies", x => x.Id);
                    table.ForeignKey(
                        name: "FK_AbpPolicies_AbpUsers_CreatorUserId",
                        column: x => x.CreatorUserId,
                        principalTable: "AbpUsers",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_AbpPolicies_AbpPolicyCates_PolicyCateId",
                        column: x => x.PolicyCateId,
                        principalTable: "AbpPolicyCates",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_AbpPolicies_AbpRegions_RegionId",
                        column: x => x.RegionId,
                        principalTable: "AbpRegions",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                });

            migrationBuilder.CreateTable(
                name: "AbpServes",
                columns: table => new
                {
                    Id = table.Column<long>(nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    Title = table.Column<string>(maxLength: 256, nullable: false),
                    ImageUrl = table.Column<string>(maxLength: 512, nullable: true),
                    ShortDesc = table.Column<string>(maxLength: 512, nullable: true),
                    Content = table.Column<string>(nullable: false),
                    Hits = table.Column<int>(nullable: false),
                    RegionId = table.Column<int>(nullable: true),
                    ServeCateId = table.Column<int>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_AbpServes", x => x.Id);
                    table.ForeignKey(
                        name: "FK_AbpServes_AbpUsers_CreatorUserId",
                        column: x => x.CreatorUserId,
                        principalTable: "AbpUsers",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_AbpServes_AbpRegions_RegionId",
                        column: x => x.RegionId,
                        principalTable: "AbpRegions",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_AbpServes_AbpServeCates_ServeCateId",
                        column: x => x.ServeCateId,
                        principalTable: "AbpServeCates",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateIndex(
                name: "IX_AbpCommerceCates_ParentId",
                table: "AbpCommerceCates",
                column: "ParentId");

            migrationBuilder.CreateIndex(
                name: "IX_AbpCommerces_CommerceCateId",
                table: "AbpCommerces",
                column: "CommerceCateId");

            migrationBuilder.CreateIndex(
                name: "IX_AbpCommerces_CreatorUserId",
                table: "AbpCommerces",
                column: "CreatorUserId");

            migrationBuilder.CreateIndex(
                name: "IX_AbpCommerces_RegionId",
                table: "AbpCommerces",
                column: "RegionId");

            migrationBuilder.CreateIndex(
                name: "IX_AbpEnterpriseCates_ParentId",
                table: "AbpEnterpriseCates",
                column: "ParentId");

            migrationBuilder.CreateIndex(
                name: "IX_AbpEnterprises_CreatorUserId",
                table: "AbpEnterprises",
                column: "CreatorUserId");

            migrationBuilder.CreateIndex(
                name: "IX_AbpEnterprises_EnterpriseCateId",
                table: "AbpEnterprises",
                column: "EnterpriseCateId");

            migrationBuilder.CreateIndex(
                name: "IX_AbpEnterprises_RegionId",
                table: "AbpEnterprises",
                column: "RegionId");

            migrationBuilder.CreateIndex(
                name: "IX_AbpPolicies_CreatorUserId",
                table: "AbpPolicies",
                column: "CreatorUserId");

            migrationBuilder.CreateIndex(
                name: "IX_AbpPolicies_PolicyCateId",
                table: "AbpPolicies",
                column: "PolicyCateId");

            migrationBuilder.CreateIndex(
                name: "IX_AbpPolicies_RegionId",
                table: "AbpPolicies",
                column: "RegionId");

            migrationBuilder.CreateIndex(
                name: "IX_AbpPolicyCates_ParentId",
                table: "AbpPolicyCates",
                column: "ParentId");

            migrationBuilder.CreateIndex(
                name: "IX_AbpServeCates_ParentId",
                table: "AbpServeCates",
                column: "ParentId");

            migrationBuilder.CreateIndex(
                name: "IX_AbpServes_CreatorUserId",
                table: "AbpServes",
                column: "CreatorUserId");

            migrationBuilder.CreateIndex(
                name: "IX_AbpServes_RegionId",
                table: "AbpServes",
                column: "RegionId");

            migrationBuilder.CreateIndex(
                name: "IX_AbpServes_ServeCateId",
                table: "AbpServes",
                column: "ServeCateId");
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "AbpCommerces");

            migrationBuilder.DropTable(
                name: "AbpEnterprises");

            migrationBuilder.DropTable(
                name: "AbpHomeSliders");

            migrationBuilder.DropTable(
                name: "AbpPolicies");

            migrationBuilder.DropTable(
                name: "AbpServes");

            migrationBuilder.DropTable(
                name: "AbpCommerceCates");

            migrationBuilder.DropTable(
                name: "AbpEnterpriseCates");

            migrationBuilder.DropTable(
                name: "AbpPolicyCates");

            migrationBuilder.DropTable(
                name: "AbpServeCates");
        }
    }
}
